﻿using System.Diagnostics;
using System.Disposables;
using Collab.Modules.Sessions;
using EnvDTE80;
using Microsoft.VisualStudio.TextManager.Interop;

namespace Collab.Modules.Session
{
    public class CollaborationSessionFactory
    {
        private readonly CompositeDisposable disposable = new CompositeDisposable();
        private readonly DTE2 dte;
        private readonly IVsTextManager textManager;
        private readonly DocumentTracker documentTracker;
        private readonly StateTracker stateTracker;

        public CollaborationSessionFactory(DTE2 dte, IVsTextManager textManager)
        {
            Debug.Assert(dte != null);
            Debug.Assert(textManager != null);
            this.dte = dte;
            this.textManager = textManager;
            this.documentTracker = new DocumentTracker(this.dte, this.textManager);
            this.stateTracker = new StateTracker(this.dte);
        }

        public CollaborationHostSession HostSession(string name)
        {
            return new CollaborationHostSession(name, this.documentTracker, this.stateTracker, new SolutionBuilder(this.dte));
        }

        public CollaborationClientSession JoinSession(string name, string ip)
        {
           
            return new CollaborationClientSession(name, this.documentTracker, this.stateTracker, ip, new SolutionBuilder(this.dte));
        }


    }
}
